/*
  Copyright (c) 2006-2009 by HAO jing <haojingus@gmail.com>
  This file is part of the SVG library. http://libsvg.googlecode.com

  This software is distributed under a license. The full license
  agreement can be found in the file LICENSE in this distribution.
  This software may not be copied, modified, sold or distributed
  other than expressed in the named license agreement.

  This software is distributed without any warranty.
*/
#ifndef SVGEXTENSION_H__
#define SVGEXTENSION_H__

#include "gloox.h"
#include "tag.h"
#include "svgtag.h"

namespace gloox
{
	enum SvgExtensionType
	{
		SvgExtLine,
		SvgExtRect,
		SvgExtText,
		SvgExtPolygon,
		SvgExtCircle,
		SvgExtDesc
	};
	class SVG_API SvgExtension
	{
	public:
		SvgExtension(){};
		virtual ~SvgExtension(){};

	public:
		virtual SvgExtension* newInstance(Tag* tag) = 0;

		virtual Tag* tag() const = 0;

		int extensionType() const;



		CSS parse(const std::string& cssCode)
		{
			//printf("info %s\n",cssCode.c_str());
			char** szStyle = new char*[4096];
			
			int iSize = str_split(cssCode.c_str(),szStyle,";",":");

			CSS CssDict ={"","","","","","","",""};
			getCssAttribute(szStyle,iSize,&CssDict);
			delete [] szStyle;
			return CssDict;
		};

		CSS getCSS()
		{
			Tag* CTag	= this->tag();
			CSS	CSS_base	=	{"","","","","","","",""};
			if(CTag->hasAttribute("style"))
			{
				CSS_base	= parse(CTag->findAttribute("style"));
				//m_css	= (tag)
				return CSS_base;
			}
			else
			{
				SVG_LOG("error svg cmd");
				return CSS_base;

			}
			//CSS_base.class_name	= "";
			//CSS_base.class_name	= CTag->findAttribute("class").c_str();
			if(CTag->hasAttribute("class"))
				strcpy(CSS_base.class_name,CTag->findAttribute("class").c_str());
				

		}
	private:
		
		int m_extensionType;

	};
}
#endif